<template>
  <div class="forget-page">
    <div class="xm-form-1">
      <div class="input-group flex border-bottom">
        <label>新密码</label>
        <input type="password" v-model.trim="form.pwd" class="flex-1"  placeholder="请输入新密码" autocomplete="off">
        <i class="close" v-show="form.pwd!=''" @click="form.pwd=''"></i>
        <p class="error" v-show="tips.pwd">{{tips.pwd}}</p>
      </div>
      <div class="input-group flex border-bottom">
        <label>确认密码</label>
        <input type="password" v-model.trim="form.rePwd" class="flex-1"  placeholder="请再次输入密码" autocomplete="off">
        <i class="close" v-show="form.rePwd!=''" @click="form.rePwd=''"></i>
        <p class="error" v-show="tips.rePwd">{{tips.rePwd}}</p>
      </div>
      <a href="javascript:;" id="next" class="btn btn1 next" @click="next">下一步</a>
    </div>

  </div>
</template>
<script>
  let reg = /((?=.*\d)(?=.*\D)|(?=.*[a-zA-Z])(?=.*[^a-zA-Z]))^.{6,16}$/;
    export default {
        props: {},
        data() {
            return {
                form:{
                    pwd: '',
                    rePwd: ''
                },
                tips: {
                    pwd: null,
                    rePwd: null,
                    notice: null
                }
            };
        },
        methods: {
            next(){
                if(this.verify()){
                    rePwd({password: this.form.pwd}).then(data=>{
                        if(data.returnCode == '000000'){
                            this.$router.push({'name': 'pwdSuc'});
                        }else{
                            this.tips.notice = data.errorMsg;
                        }
                    });
             }
            },
            verify(){
                this.tips = {
                    pwd: null,
                    rePwd: null,
                    notice: null
                }
                if(!reg.test(this.form.pwd)){
                   this.tips.pwd = '密码为6~16位2种以上字符组合';
                   return false;
                }
                if(this.form.pwd != this.form.rePwd){
                  this.tips.rePwd = '密码输入不一致';
                  return false;
                }
                return true;
            }
        },
        filters: {},
        created() {

        },
        mounted(){

        },
        components: {
        }
    };
</script>
<style lang="less" scoped>
  @import "../login/login.less";
  .forget-page{
    height: 100%;
    background: #fff;
  }
</style>

